package cn.tedu.lbs.marketing.web.controller;

import cn.tedu.lbs.marketing.web.service.ActivityService;
import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.pojo.marketing.param.ActivityParam;
import com.tarena.lbs.pojo.marketing.query.ActivityQuery;
import com.tarena.lbs.pojo.marketing.vo.ActivityVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//活动模块的http接口
@RestController
public class ActivityController {
    @Autowired
    private ActivityService activityService;
    //商家活动列表分页查询
    @PostMapping("/admin/marketing/marketingActivity/info/list")
    public Result<PageResult<ActivityVO>> pageList(@RequestBody ActivityQuery query)
        throws BusinessException{
        return new Result<>(activityService.pageList(query));
    }
    //商家活动录入新增
    @PostMapping("/admin/marketing/marketingActivity/info/save")
    public Result<Void> save(@RequestBody ActivityParam param)
        throws BusinessException{
        activityService.save(param);
        return Result.success();
    }
    //文章中查看携带活动的详情
    @GetMapping("/admin/marketing/marketingActivity/info/detail/{id}")
    public Result<ActivityVO> detail(@PathVariable("id") Integer id)
        throws BusinessException{
        return new Result<>(activityService.detail(id));
    }
}
